<?php

namespace App\Http\Controllers\App;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\User;
use App\Models\Shop;

class ShopController extends Controller
{ 
    /**
     * 获取运营者信息
     * @param  Request $request [description]
     * @return [type]           [description]
     */
    public function operator( Request $request )
    {
        $id = $request->input('id', 0);

        $shop_id = User::where('id', $id)->value('shop_id');

        $field = ['shopname', 'shopuser', 'phone', 'province', 'city', 'area', 'address', 'latitude', 'longitude'];

        $shop_ifno = Shop::where('id', $shop_id)->select($field)->first()? : Shop::where('login', '80000')->select($field)->first();

        return self::json($shop_ifno);
    }

    /**
     * 获取所有店铺列表
     * 
     */
    public function shopLists( Request $request )
    {
        $shops = Shop::where('status','1')->where('isdelete','0')->select('id','shopname','phone','address','latitude','longitude')->get();

        return self::json($shops);
    }
}
